#ifndef __BUOLA_GL_CRENDERBUFFER_H__
#define __BUOLA_GL_CRENDERBUFFER_H__

#include <buola/gl.h>

namespace buola { namespace gl {

class CRenderBuffer
{
public:
    CRenderBuffer()
        :   mID(0)
    {}

    ~CRenderBuffer()
    {
        if(mID)
            Delete();
    }

    void Create()
    {
        if(mID) Delete();
        glGenRenderbuffers(1,&mID);
    }

    void SetupStorage(GLenum pFormat,const CSize_i &pSize)
    {
        glRenderbufferStorage(GL_RENDERBUFFER,pFormat,pSize.x,pSize.y);
    }

    void Bind()
    {
        glBindRenderbuffer(GL_RENDERBUFFER,mID);
    }

    static void Unbind()
    {
        glBindRenderbuffer(GL_RENDERBUFFER,0);
    }

    void Delete()
    {
        glDeleteRenderbuffers(1,&mID);
        mID=0;
    }

    GLuint GetID() const      {   return mID; }

private:
    GLuint mID;
};

/*namespace gl*/ } /*namespace buola*/ }

#endif
